package com._51cto.healthy.service;

import com._51cto.healthy.base.BaseMapper;
import com._51cto.healthy.content.P;
import com._51cto.healthy.mapper.ExaminationMapper;
import com._51cto.healthy.pojo.Examination;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/****
 * @Author:DancingHorse
 * @Description:TMember业务层接口实现类
 * @Date 2022/4/14 0:16
 *****/
@DubboService
public class ExaminationServiceImpl implements ExaminationService {

    @Autowired
    private ExaminationMapper baseMapper;

    public BaseMapper<Examination> getDao(){
        return baseMapper;
    }

    @Override
    public P<Examination> queryPageList(String query, Integer pageNum, Integer pageSize) {
        //开启分页
        PageHelper.startPage(pageNum,pageSize);
        //获取数据库数据
        List<Examination> setMeals = baseMapper.queryPageList(query);
        //把获取到的数据存入pageInfo
        PageInfo<Examination> pageInfo = new PageInfo<>(setMeals);
        return new P()
                .setPageNum(pageInfo.getPageNum())
                .setPageSize(pageInfo.getPageSize())
                .setPages(pageInfo.getPages())
                .setRows(pageInfo.getList())
                .setTotal(pageInfo.getTotal());
    }

    @Override
    public void deleteByPK(Integer id) {
        baseMapper.deleteByPK(id);
    }
}
